#ifndef __SERVER__H__
#define __SERVER__H__

enum cmd_key_e
{
	CLIENT_CMD_KEY_SWITCH,
	CLIENT_CMD_KEY_CO2,
	CLIENT_CMD_KEY_SOIL,
	CLIENT_CMD_KEY_ILL,
	CLIENT_CMD_KEY_PM,
	CLIENT_CMD_KEY_AIR,
	CLIENT_CMD_KEY_FLAMGAS,
	CLIENT_CMD_KEY_SLEET,
	CLIENT_CMD_KEY_SMOG,
	CLIENT_CMD_KEY_INFRARED,
	CLIENT_CMD_KEY_FAN,
	CLIENT_CMD_KEY_IRR,
	CLIENT_CMD_KEY_SUNSHADE,
	CLIENT_CMD_KEY_ALARM,
	CLIENT_CMD_KEY_LAMP,
	CLIENT_CMD_KEY_DOORLOOK,
	CLIENT_CMD_KEY_MAX
};

union val_t
{
    int b_val;  //bool类型存储空间
    int i_val;   //整形值存储空间
    float f_val;  //浮点值存储空间
    char s_val[32];  //字符串类型
};

typedef struct node_data
{
    int key;  //唯一键值
    char name[128];
    int type;  //数据点类型
    int used;  //是否有效，有几个点只是为了好看，没有实际设备
    union val_t val;
}node_t;

#define CONTROL_CMD_LEN sizeof(node_t)
#define CTRL_PUB_TOPIC "ScratchToSoftWare"

int init_network(int port);
int send_data(node_t data);
void close_network();
int get_client_ctrl();
#endif
